[Previous] [Next]

The ProgressBar Control

The ProgressBar control is used to inform the user about the progress state of a lengthy operation. This control is the simplest one among those contained in the MsComCtl.OCX file because it doesn't have any dependent objects and it doesn't expose any custom events.

Setting Design-Time Properties

You have to set up a few properties at design time after you drop a ProgressBar control on a form; in most cases, you can accept the default values. The most important properties are Min and Max, which determine the minimum and maximum values that can be displayed by the progress bar.

The ProgressBar control that comes with Visual Basic 6 includes two new properties, Orientation and Scrolling. The former lets you create vertical progress bars; the latter lets you alternate between a standard segmented bar and a smoother bar, as you can see in Figure 10-24. You can change these values even at run time.

Run-Time Operations

There isn't much to say about run-time interaction with the ProgressBar control. In practice, the only thing you can do through code is set the Value property to a number in the range from Min to Max. Any value outside this interval fires an error 380 "Invalid property value." As I mentioned previously, the ProgressBar control doesn't expose any custom events.

Click to view at full size.

Figure 10-24. The effects of the Orientation, Scrolling, Appearance, and BorderStyle properties on the ProgressBar control.

Only two other properties affect the aspect of the control—Appearance and BorderStyle. Figure 10-24 shows a number of possible combinations of these properties.